package com.gzs.zhdj.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 响应用户请求封装工具类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResponse {
    public static final String OK = "200"; //默认响应码（200表示正常）
    public String code;    //响应码
    public String message; //响应描述信息
    public Object data;    //响应数据

    public static CommonResponse ok() {return new CommonResponse(OK,"success",null);}
    public static CommonResponse ok(Object data) {
        return new CommonResponse(OK,"success",data);
    }

    public static CommonResponse fail(String message) {

        return new CommonResponse("0",message,null);
    }

    public static CommonResponse set(String code,String message,Object data) {
        return new CommonResponse("0",message,data);
    }
}
